import React, {Component} from 'react'
import {
    Link
} from 'react-router-dom'
export default class Result extends Component {
    onFilter(value){
        if(value/1000 > 1) {
            return (value/10000).toPrecision(2) + '万'
        } else {
            return value
        }
    }
    render(){
        const { book } = this.props
        return(
            <div className="result">
                <Link to={'/book/'+book._id}>
                    <div className="searchResult">
                        <div className="leftCover">
                            <img src={'http://statics.zhuishushenqi.com'+book.cover} alt={book.title}/>
                        </div>
                        <div className="rightIntro">
                            <div className="title">
                                {book.title}
                            </div>
                            <div className="authorAndType">
                                {book.author} | {book.cat}
                            </div>
                            <div className="smallIntro">
                                {book.shortIntro}
                            </div>
                            <div className="readNumberAndReadExist">
                                <span 
                                    className="readColor">{this.onFilter(book.latelyFollower)}</span>人气 |  
                                <span 
                                    className="readColor">{book.retentionRatio?book.retentionRatio:0}%</span>读者留存
                            </div>
                        </div>
                    </div>
                </Link>
            </div>
        )
    }
}